package com.tqjc.system.core.threadpool;

import com.tqjc.system.core.util.SpringUtils;

import java.util.concurrent.ThreadPoolExecutor;

/**
 * @Author: 86195
 * @CreateTime: 2024-05-20  09:58
 * @Description: TODO
 * @Version: 1.0
 */
public class ThreadPoolManager {

    private ThreadPoolManager() {
    }


    private static ThreadPoolManager instance = new ThreadPoolManager();


    private ThreadPoolExecutor threadPool = SpringUtils.getBean("threadPoolExecutor");


    public static ThreadPoolManager getInstance(){
        return instance;
    }

    public void execute(Runnable runnable){
        threadPool.execute(runnable);
    }


    public void shutdown(){
        if(threadPool != null && !threadPool.isShutdown()){
            threadPool.shutdown();
        }

    }



}
